package com.mzj.saas.jobs.bill.executor;

import com.mzj.saas.jobs.bill.service.SupplementUserInfoService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


/**
 * 补齐用户信息
 */
@JobHandler(value = "supplementUserInfoExecutor")
@Component
public class SupplementUserInfoExecutor extends IJobHandler {

    private static Logger log = LoggerFactory.getLogger(SupplementUserInfoExecutor.class);

    @Autowired
    private SupplementUserInfoService supplementUserInfoService;


//    /**
//     * 每30秒统计一次
//     */
//    @Scheduled(cron = "0/30 * * * * ?")
//    public void executor() {
//        try {
//            supplementUserInfoService.work();
//
//        } catch (Exception e) {
//            log.error(e.getMessage() + "补齐用户信息异常", e);
//        }
//    }


    @Override
    public ReturnT<String> execute(String s) throws Exception {

        long time = System.currentTimeMillis();

        String result = supplementUserInfoService.work();

        long useTime = System.currentTimeMillis() - time;
        log.info("----> SupplementUserInfoExecutor end, result: {}, use time: {}", result, useTime);

        return SUCCESS;
    }
}
